namespace Digitalmes.Domain.Entities.Mes.Equipments;

/// <summary>
/// 设备点检记录。
/// </summary>
[SugarTable("equip_inspection_record")]
public sealed class EquipInspectionRecord : EntityBase
{
    /// <summary>
    /// 计划 Id。
    /// </summary>
    public long PlanId { get; set; }

    /// <summary>
    /// 设备 Id
    /// </summary>
    public long MachineryId { get; set; }

    /// <summary>
    /// 设备编码
    /// </summary>
    [NotNull]
    public string? MachineryCode { get; set; }

    /// <summary>
    /// 设备名称
    /// </summary>
    [NotNull]
    public string? MachineryName { get; set; }

    /// <summary>
    /// 点检类型（手动/自动）
    /// </summary>
    [SugarColumn(SqlParameterDbType = typeof(EnumToStringConvert))]
    public InspectTypeEnum InspectType { get; set; }

    /// <summary>
    /// 设备所在产线 Id。
    /// </summary>
    public long LineId { get; set; }

    /// <summary>
    /// 设备所在工位 Id，0 表示不存在。
    /// </summary>
    public long WorkstationId { get; set; }

    /// <summary>
    /// 设备所在工位号
    /// </summary>
    public string? WorkstationCode { get; set; }

    /// <summary>
    /// 标件编号，没有可为 null。
    /// </summary>
    public string? StandardPartNo { get; set; }

    /// <summary>
    /// 点检时间
    /// </summary>
    public DateTime InspectionTime { get; set; }

    /// <summary>
    /// 点检人员（手动点检设置）
    /// </summary>
    public string? Inspector { get; set; }

    /// <summary>
    /// 点检最终结果（合格/不合格）
    /// </summary>
    [SugarColumn(SqlParameterDbType = typeof(EnumToStringConvert))]
    public QualifiedEnum Result { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    public string? Remark { get; set; }

    /// <summary>
    /// 点检数据集合。
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(EquipInspectionData.RecordId))]
    public List<EquipInspectionData>? Data { get; set; }
}
